<?php

namespace app\admin\controller;

use app\common\controller\AdminBase;
use think\Db;
use think\Request;

class Statistic extends AdminBase{

    public function index(){
        $pay_num = $this->getPayPerson();
        $total = $this->getTotal();
        return $this->fetch('index',[
            'pay_num' => $pay_num,
            'total' => $total
        ]);
    }

    protected function getPayPerson(){
        $pay_ok_num = Db::table('os_money')->where('status = 1')->count();
        $pay_no_num = Db::table('os_money')->where('status = 0')->count();
        return [
            'pay_ok_num' => $pay_ok_num,
            'pay_no_num' => $pay_no_num
        ];
    }

    protected function getTotal(){
        $total = Db::table('os_money')->sum('prac_amount');
        return $total;
    }
}